<template>
  <div>
    <video ref="videoElement" controls width="100%" height="100%" muted></video>
  </div>
</template>

<script>
import flvjs from 'flv.js';

export default {
  name: 'FlvPlayer',
  props: {
    src: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      player: null,
    };
  },
  mounted() {
    if (flvjs.isSupported()) {
      const videoElement = this.$refs.videoElement;
      this.player = flvjs.createPlayer({
        type: 'flv',
        url: this.src,
      });
      this.player.attachMediaElement(videoElement);
      this.player.load();
      this.player.play();
    }
  },
  beforeUnmount() {
    if (this.player) {
      this.player.destroy();
      this.player = null;
    }
  },
};
</script>

<style scoped>
/* 你可以在这里添加一些样式 */
</style>